package com.bmw.bingfa.controller;

import com.bmw.bingfa.entity.CommonWebUser;
import com.bmw.bingfa.model.http.TicketReq;
import com.bmw.bingfa.security.WebUserUtil;
import com.bmw.bingfa.service.TicketService;
import com.bmw.bingfa.service.UserService;
import com.bmw.bingfa.util.ErrorMessage;
import com.bmw.bingfa.util.bean.BaseRequest;
import com.bmw.bingfa.util.bean.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Objects;

/**
 * Classname: TicketController
 * Package: com.bmw.bingfa.controller
 * Description:
 *
 * @Author 余集楠
 * @Create 2024/5/29 0029 17:21
 * @Version 1.8
 */
@RestController
@RequestMapping(value="/ticket")
@Slf4j
public class TicketController {
    @Autowired
    TicketService ticketService;

    @Autowired
    UserService userService;

    @PostMapping(value="/order")
    public BaseResponse order(@Valid @RequestBody TicketReq req){


         return BaseResponse.OK(ticketService.Order(req));
    }

    //用悲观锁防止并发下单的接口
//    @PostMapping(value="/pessimistic/order")
//    public BaseResponse pOrder(@Valid @RequestBody TicketReq req){
//        return BaseResponse.OK(ticketService.pOrder(req));
//    }
}
